<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:82:"/webHome/host6366235/www/public/../application/admin/view/applys/update_major.html";i:1684984582;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $setting['webname']; ?> - 修改专业</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="/public/static/admin/layui/css/layui.css" rel="stylesheet">
    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">


    <style>
        #demo2 img{
            height: 110px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>报名记录</h2>
        <ol class="breadcrumb">
            <li>
                <a href="<?php echo url('Admins/admin'); ?>">主页</a>
            </li>
            <li>
                <strong>修改专业</strong>
            </li>
        </ol>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改专业</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" id="form1">
                        <!--`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',-->
                        <input type="hidden" name="id" value="<?php echo $apply['id']; ?>" class="form-control">
                        <input type="hidden" name="pid" value="<?php echo $pid; ?>" class="form-control">

                        <!--姓名-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">姓名：</label>
                            <div class="col-sm-6">
                                <input type="text" placeholder="请输入报名人姓名" id="name" value="<?php echo $user['name']; ?>" class="form-control" readonly>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--报考类别-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">报考类别：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="bktype" id="examtype">
                                    <?php foreach($examtype as $val): ?>
                                        <option value="<?php echo $val['name']; ?>" data-id="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--报考类别-->
                        <div class="form-group" id="coursetype_div">
                            <label class="col-sm-2 control-label">专业大类：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="coursetype_name" id="coursetype">
                                    <option value="" data-id="">==专业大类==</option>
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--专业1-->
                        <div class="form-group" id="major_div">
                            <label class="col-sm-2 control-label">专业1：</label>
                            <div class="col-sm-6">

                                <select class="form-control m-b" name="major" id="major">
                                    <option value="" data-id="">==专业1==</option>

                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--报考类别-->
                        <div class="form-group" id="coursetype_div2">
                            <label class="col-sm-2 control-label">专业大类2：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="coursetype_name2" id="coursetype2">
                                    <option value="" data-id="">==专业大类2==</option>
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--专业2-->
                        <div class="form-group" id="major_div2">
                            <label class="col-sm-2 control-label">专业2：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="major2" id="major2">
                                    <option value="" data-id="">==专业2==</option>

                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--专业2-->
                        <div class="form-group" id="isadjust_div">
                            <label class="col-sm-2 control-label">是否调剂：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="isadjust" id="isadjust">
                                    <option value="" data-id="">==是否调剂==</option>
                                    <option value="是">是</option>
                                    <option value="否">否</option>
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--负责老师-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">负责老师：</label>
                            <div class="col-sm-6">
                                <select class="form-control m-b" name="teacher" id="teacher">
                                    <option value="" data-id="">==负责老师==</option>
                                    <?php foreach($teacher as $val): ?>
                                    <option value="<?php echo $val['name']; ?>" data-id="<?php echo $val['id']; ?>"><?php echo $val['name']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                        <!--确认-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-6">
                                <button type="button" class="btn btn-info btn-sm btn-block" id="save"> 保存修改</button>
                            </div>
                            <div class='col-sm-4'></div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="/public/static/admin/layui/layui.js"></script>
<script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="/public/static/admin/js/content.js?v=1.0.0"></script>
<script src="/public/static/admin/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
<script src="/public/static/home/script/distpicker.data.js"></script>
<script src="/public/static/home/script/distpicker.js"></script>
<script src="/public/static/home/script/main.js"></script>


<script>
    //单选和复选框
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });
    //初始化学员的专业
    var bktype = "<?php echo $apply['bktype']; ?>"
    var teacher = "<?php echo $apply['teacher']; ?>"
    var major = "<?php echo $apply['major']; ?>"
    var major2 = "<?php echo $apply['major2']; ?>"
    var isadjust = "<?php echo $apply['isadjust']; ?>"
    var bktypeid = "<?php echo $apply['bktype_id']; ?>"
    var coursetype_id = "<?php echo $apply['coursetype_id']; ?>"
    var coursetype_id2 = "<?php echo $apply['coursetype_id2']; ?>"
    var coursetype_name = "<?php echo $apply['coursetype_name']; ?>"
    var coursetype_name2 = "<?php echo $apply['coursetype_name2']; ?>"

    $("#examtype option[value='"+bktype+"']").prop("selected",true)
    if(teacher != "") {
        $("#teacher option[value='"+teacher+"']").prop("selected", true)
    }
    $("#isadjust option[value="+isadjust+"]").prop("selected",true);
    //根据报考类型查询专业大类
    function select_coursetype(bkid){
        //清空之前的选项
        $("#coursetype").text("");
        $("#coursetype").append("<option value=\"\" data-id=\"\">==专业大类==</option>");
        //专业大类2
       $("#coursetype2").text("");
       $("#coursetype2").append("<option value=\"\" data-id=\"\">==专业大类2==</option>");
        $.post("<?php echo url('Applys/select_coursetype'); ?>",{'examtype_id':bkid},function(data){
            if(data.length >0){
                $("#coursetype_div").show();
                $("#coursetype_div2").show();
                //重新添加当前报考类型的专业大类
                for(val of data){
                    $("#coursetype").append($("<option value='"+val.name+"' data-id='"+val.id+"'>"+val.name+"</option>"));
                    $("#coursetype2").append($("<option value='"+val.name+"' data-id='"+val.id+"'>"+val.name+"</option>"));
                }
                //当前报名学生选择的专业大类
                $("#coursetype option[value="+coursetype_name+"]").prop("selected",true);
                $("#coursetype2 option[value="+coursetype_name2+"]").prop("selected",true);
                //当选择专报考类型是，专业大类改变，连带改变专业1和专业2的选项

            }else{
                $("#coursetype_div").hide();
                $("#coursetype_div2").hide();
            }
        })
    }
    select_coursetype(bktypeid); //刷新的时候自动加载一次
    //报考类型发生变化的时候重新查询追加“专业大类”
    $("#examtype").on("change",function(){
        //获取当前被选中的下拉列表的报考类型的id
       var bkid =  $(this).find("option:selected").attr("data-id")
        select_coursetype(bkid);
    })
    //-------------------------------------------
    //根据专业大类查询专业
    function select_major(c_id){
      console.log(c_id);
      //清空之前的选项
        $("#major").text("");
        $("#major").append("<option value=\"\" data-id=\"\">==专业1==</option>");
        $.post("<?php echo url('Applys/select_major'); ?>",{'coursetype_id':c_id},function(data){
            if(data.length >0){
                //如果有专业选择，显示下拉列表，并重新添加当前专业大类下的专业
                $("#major_div").show();
                for(val of data){
                    $("#major").append($("<option value='"+val.name+"' data-id='"+val.id+"'>"+val.name+"</option>"));
                }
                $("#major option[value="+major+"]").prop("selected",true);
            }else{
                $("#major_div").hide();
            }
        });
    }
    select_major(coursetype_id);
    //专业2
    function select_major2(c_id){
      //清空之前的选项
      $("#major2").text("");
      $("#major2").append("<option value=\"\" data-id=\"\">==专业2==</option>");
      $.post("<?php echo url('Applys/select_major'); ?>",{'coursetype_id':c_id},function(data){
        if(data.length >0){
          $("#major2_div").show();
          for(val of data){
            $("#major2").append($("<option value='"+val.name+"' data-id='"+val.id+"'>"+val.name+"</option>"));
          }
          $("#major2 option[value="+major2+"]").prop("selected",true);
        }else{
          $("#major2_div").hide();
        }
      });
    }
    select_major2(coursetype_id2);
    //当专业大类发生变化的时候重新查询“专业”
    $("#coursetype").on("change",function(){
        var c_id = $(this).find("option:selected").attr("data-id");
        select_major(c_id);
    });
    $("#coursetype2").on("change",function(){
      var c_id = $(this).find("option:selected").attr("data-id");
      select_major2(c_id);
    });

    //-------------------------------------------
    layui.use('upload', function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload; //独立版的layer无需执行这一句
        //获取性别
        $("#save").click(function () {
            var form1  = $("#form1").serializeArray();
            data = {}
            form1.forEach(function(val){
                data[val.name] = val.value;
            })
            data['teacher_id'] = $("#teacher option:selected").data("id");
            data['bktype_id'] = $("#examtype option:selected").data("id");
            data['coursetype_id'] = $("#coursetype option:selected").data("id");
            data['coursetype_id2'] = $("#coursetype2 option:selected").data("id");
            data['major_id'] = $("#major option:selected").data("id");
            data['major2_id'] = $("#major2 option:selected").data("id");
            $.post("<?php echo url('Applys/save_update_major'); ?>", data, function (data) {
                top.layer.msg(data.msg, {time: 2000,shade:0.5}, function () {
                    if (data.url) {
                        window.location.href = data.url;
                    }
                });
            });
        });
    });

    $(".check").click(function(){
        if($(this).attr('class') == "fa fa-square-o check"){
            $(this).attr('class',"fa fa-check-square-o check");
        }else{
            $(this).attr('class',"fa fa-square-o check");
        }
    });

</script>
<!-- SUMMERNOTE -->
<script src="/public/static/admin/js/plugins/summernote/summernote.min.js"></script>
<script src="/public/static/admin/js/plugins/summernote/summernote-zh-CN.js"></script>
<script>
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });
</script>

</body>
</html>
